package com.example.leetcode;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;

public class HW10 {
    public static void main(String[] args) {
        String s ="-1 -3 7 5 11 15";
        String[] strings =s.split(" ");
        List<Integer> nums = Arrays.stream(strings).map(Integer::parseInt).collect(Collectors.toList());
        //排序的Arrays.stream(strings).map(Integer::parseInt).sorted().collect(Collectors.toList());
     nums.stream().sorted();
        HashMap<Integer,String> map = new HashMap<>();
     List<Integer> list = new ArrayList<>();
        for (int i=0;i<nums.size();i++){
            for (int j=i+1;j<nums.size();j++){
                int sum = nums.get(i) +nums.get(j);
                if (sum<0){
                    sum=0-sum;
                }
                list.add(sum);
                map.put(sum,nums.get(i) +" "+nums.get(j));

            }
        }
      int sum =  list.stream().reduce(Integer::min).get();
     String s1=   map.get(sum);

        System.out.println(s1+" "+sum);
    }
}
